//451.根据字符出现频率排序
//https://leetcode.cn/problems/sort-characters-by-frequency/
class Solution {
public:
    string frequencySort(string s) {
        unordered_map<char, int> hash;
        for (char c : s) ++hash[c];
        priority_queue<pair<int, char>> pq;
        for(auto& [k,v]:hash) pq.push({v,k});
        s.clear();
        while(!pq.empty())
        {
            s.append(pq.top().first,pq.top().second);
            pq.pop();
        }
        return s;
    }
};